/**
 * API 响应类型定义
 * 基于接口文档中的标准响应格式
 */

// 基础API响应结构
export interface ApiResponse<T = any> {
  code: number
  success?: boolean
  msg: string
  data: T
  timestamp?: string
}

// API相关的业务类型已移动到对应的模块中
// 例如：StockRecommendation 和 GetRecommendationsParams 现在在 lib/api/recommendations.ts

// API错误类型
export interface ApiError {
  code: number
  message: string
  details?: any
}

// axios 相关类型已在 http-client.ts 中直接使用 AxiosRequestConfig

// 登录相关类型
export interface LoginRequest {
  username: string
  password: string
}

export interface LoginResponse {
  user_id: number
  username: string
  token: string
}

// 注册相关类型
export interface RegisterRequest {
  username: string
  email: string
  password: string
  confirmPassword: string
  trueName?: string
  phone?: string
}

export interface RegisterResponse {
  success: boolean
  message: string
  userInfo?: {
    username: string
    userId: string
    nickname?: string
    email?: string
  }
}

// 关注相关类型
export interface WatchRequest {
  stock_code: string
  action: 'add' | 'remove'
}

export interface WatchResponse {
  success: boolean
  watched_stocks: string[]
}

// API端点配置
export const API_ENDPOINTS = {
  BASE_URL: process.env.NEXT_PUBLIC_API_BASE_URL || 'https://tczlld.com/trade',
  RECOMMENDATIONS: '/api/recommendations',
  EXECUTE_BUY: '/api/trades/manual-buy',
  EXECUTE_SELL: '/api/trades/manual-sell',
  LOGIN: '/api/auth/login',
  REGISTER: '/api/auth/register',
  WATCHLIST: '/api/watchlist/',
  WATCHLIST_CHECK: '/api/watchlist/check',
  STOCKS_LIST: '/api/stocks/list',
  STOCKS_SEARCH: '/api/stocks/search',
  STOCK_DETAIL: '/api/stocks',
} as const

// HTTP状态码
export const HTTP_STATUS = {
  OK: 200,
  CREATED: 201,
  BAD_REQUEST: 400,
  UNAUTHORIZED: 401,
  FORBIDDEN: 403,
  NOT_FOUND: 404,
  INTERNAL_SERVER_ERROR: 500,
} as const

// API业务状态码
export const API_CODES = {
  SUCCESS: 200,
  INTERNAL_ERROR: 500,
} as const